package com.zhang.admin.service.impl;

import com.zhang.admin.dao.SysRoleMapper;
import com.zhang.admin.dao.SysUserRoleMapper;
import com.zhang.admin.po.SysRole;
import com.zhang.admin.service.RoleService;
import com.zhang.admin.vo.QueryRoleByPageParams;
import com.zhang.common.core.page.Navigator;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author zsw
 * @Date 2019/10/31 14:53
 * @Version V1.0
 **/
@Service
@AllArgsConstructor
@Transactional(rollbackFor = {Exception.class})
public class RoleServiceImpl implements RoleService {

    private final SysRoleMapper sysRoleMapper;

    private final SysUserRoleMapper sysUserRoleMapper;

    @Override
    public List<SysRole> queryRolesByUserId(Integer userId){
        List<SysRole> sysRoleList = new ArrayList<>();
        return sysRoleList;
    }

    @Override
    public void createRole(SysRole sysRole) {
        //TODO 验重

        sysRoleMapper.insertSelective(sysRole);
    }

    @Override
    public void updateRole(SysRole sysRole) {
        //TODO 验重

        sysRoleMapper.updateByPrimaryKeySelective(sysRole);
    }

    @Override
    public Navigator<SysRole> queryRoleByPage(QueryRoleByPageParams queryRoleByPageParams) {
        return null;
    }

    @Override
    public void addPermission(Integer roleId, List<Integer> elementId) {

    }


}